package com.itheima.test;

import java.util.Scanner;

public class Test1改进 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您的机票原价：");
        int price = sc.nextInt();
        System.out.println("请输入当前的年份：");
        int month = sc.nextInt();
        System.out.println("请输入您的机舱类型：(0表示头等舱，1表示经济舱)");
        int seat = sc.nextInt();
        if (month >= 5 && month <= 10) {
            price = getPrice(price, seat,0.9, 0.85);
        } else if ((month >= 1 && month <= 4) || (month >= 11 && month <= 12)) {
            price = getPrice(price, seat, 0.7, 0.65);
        } else {
            System.out.println("不存在这个月份！");
        }
        System.out.println("您的机票价格为：" + price);
    }

    private static int getPrice(int price, int seat, double v, double v2) {
        if (seat == 0) {
            price = (int) (price * v);
        } else if (seat == 1) {
            price = (int) (price * v2);
        } else {
            System.out.println("不存在这个舱位！");
        }
        return price;
    }
}
